<div class="datatable">
  <rd-widget>
    <rd-widget-body classes="no-padding">
      <div class="toolBar">
        <div class="toolBarTitle"> <i class="fa" ng-class="$ctrl.titleIcon" aria-hidden="true" style="margin-right: 2px"></i> {{ $ctrl.titleText }} </div>
      </div>

      <div class="actionBar" ng-if="$ctrl.showSnapshotAction || $ctrl.showKubeconfigButton()">
        <div style="margin-bottom: 10px" ng-if="$ctrl.endpoints.length">
          <i class="fa fa-exclamation-circle blue-icon" style="margin-right: 5px"></i>Click on an environment to manage
        </div>
        <button type="button" ng-if="$ctrl.showSnapshotAction" class="btn btn-sm btn-primary" ng-click="$ctrl.snapshotAction()" data-cy="home-refreshEndpointsButton">
          <i class="fa fa-sync space-right" aria-hidden="true"></i>Refresh
        </button>
        <button
          ng-if="$ctrl.showKubeconfigButton()"
          type="button"
          class="btn btn-sm btn-primary"
          ng-click="$ctrl.showKubeconfigModal()"
          analytics-on
          analytics-category="kubernetes"
          analytics-event="kubernetes-kubectl-kubeconfig-multi"
        >
          <i class="fas fa-download space-right"></i> kubeconfig
        </button>
      </div>

      <div class="searchBar">
        <i class="fa fa-search searchIcon" aria-hidden="true"></i>
        <input
          type="text"
          class="searchInput"
          ng-model="$ctrl.state.textFilter"
          ng-change="$ctrl.onTextFilterChange()"
          ng-model-options="{ debounce: 300 }"
          placeholder="Search by name, group, tag, status, URL..."
          auto-focus
          data-cy="home-endpointsSearchInput"
        />
      </div>

      <div class="blocklist" data-cy="home-endpointList">
        <endpoint-item
          ng-if="$ctrl.hasBackendPagination()"
          dir-paginate="endpoint in $ctrl.state.filteredEndpoints | itemsPerPage: $ctrl.state.paginatedItemLimit"
          model="endpoint"
          total-items="$ctrl.state.totalFilteredEndpoints"
          on-select="($ctrl.dashboardAction)"
          on-edit="($ctrl.editAction)"
          is-admin="$ctrl.isAdmin"
          tags="$ctrl.tags"
          endpoint-init-time="$ctrl.endpointInitTime"
        ></endpoint-item>
        <endpoint-item
          ng-if="!$ctrl.hasBackendPagination()"
          dir-paginate="endpoint in $ctrl.state.filteredEndpoints | itemsPerPage: $ctrl.state.paginatedItemLimit"
          model="endpoint"
          on-select="($ctrl.dashboardAction)"
          on-edit="($ctrl.editAction)"
          is-admin="$ctrl.isAdmin"
          tags="$ctrl.tags"
          endpoint-init-time="$ctrl.endpointInitTime"
        ></endpoint-item>
        <div ng-if="$ctrl.state.loading" class="text-center text-muted" data-cy="home-loadingEndpoints"> Loading... </div>
        <div ng-if="!$ctrl.state.loading && !$ctrl.state.filteredEndpoints.length" class="text-center text-muted" data-cy="home-noEndpoints"> No environment available. </div>
      </div>

      <div class="footer" ng-if="$ctrl.endpoints">
        <div class="paginationControls">
          <form class="form-inline">
            <span class="limitSelector">
              <span style="margin-right: 5px"> Items per page </span>
              <select class="form-control" ng-model="$ctrl.state.paginatedItemLimit" ng-change="$ctrl.changePaginationLimit()" data-cy="home-paginationSelect">
                <option value="0" ng-if="!$ctrl.hasBackendPagination()">All</option>
                <option value="10">10</option>
                <option value="25">25</option>
                <option value="50">50</option>
                <option value="100">100</option>
              </select>
            </span>
            <dir-pagination-controls max-size="5" on-page-change="$ctrl.pageChangeHandler(newPageNumber, oldPageNumber)"></dir-pagination-controls>
          </form>
        </div>
      </div>
    </rd-widget-body>
  </rd-widget>
</div>
